<?php
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}
$loadboard = mysql_query("select e.IDEmployee, e.FullName,b.* from employee e, board b where e.IDEmployee = b.IDEmployee order by b.CreatedDate desc");
$addressbrowser = $_SERVER['SERVER_NAME'];
$temp = explode(".", $addressbrowser);
$queryDepartment = mysql_query("SELECT d.IDDepartment,dl.DepartmentName FROM department d,department_lang dl WHERE d.IDDepartment=dl.IDDepartment AND dl.LangID='$lang';");
//$querySendMail = mysql_query("SELECT e.IDEmployee,e.FullName FROM list_sendmail l,employee e WHERE l.employee_id=" . $_SESSION['IDEmployee'] . " AND e.IDEmployee=l.employee_id_sendmail GROUP BY l.employee_id_sendmail");
include 'popup/popup_reference3.php';
?>
<script type="text/javascript"src="admin/ckeditor_351/ckeditor.js"></script>
<script type="text/javascript"src="admin/ckfinder/ckfinder.js"></script>
<style>
    .cke_contents {
        height: 670px !important;
    }
    .cke_skin_kama{
        width: 100% !important;

    }
    a[title="Browse Server"] {
        display: none !important;
    }

    a[title="Duyệt trên máy chủ"] {
        display: none !important;
    }

    a[title="서버 보기"] {
        display: none !important;
    }

    a[title="Link"] {
        display: none !important;
    }

    a[title="Liên kết"] {
        display: none !important;
    }

    a[title="링크"] {
        display: none !important;
    }

    a[title="Advanced"] {
        display: none !important;
    }

    a[title="Tab mở rộng"] {
        display: none !important;
    }

    a[title="자세히"] {
        display: none !important;
    }

    tr td.cke_bottom {
        display: none !important;
    }
</style>

<script type="text/javascript">
    function setdata(id,lang,company){
        document.getElementById("orderid").value=id;
        document.getElementById("lang").value=lang;
        document.getElementById("company").value=company;
        popup_window_show('#sample', { pos : 'window-center', width : '600px', height:'800px'});
	
    }
    function showUser1(str){
        if (str==""){
            document.getElementById("txtHint").innerHTML="";
            return;
        } 
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","ajax/getuser1.php?q="+str,true);
        xmlhttp.send();
    }
    function showReference1(str){ 
        if (str==""){
            document.getElementById("txtHint1").innerHTML="";
            return;
        } 
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","ajax/getreference5.php?idemployee="+str,true);
        xmlhttp.send();
    }
    
    function rmReference1(str){ 
        if (str==""){
            document.getElementById("txtHint1").innerHTML="";
            return;
        } 
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","ajax/rmreference5.php?idemployee="+str,true);
        xmlhttp.send();
    }
    function sendmail(){
    
        var id=document.getElementById("orderid").value;
        var lang=document.getElementById("lang").value;
        var company=document.getElementById("company").value;
        //alert(id+lang+company);
	
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                //document.getElementById('showview').setAttribute('style','opacity:1; position:relative;');
                alert(xmlhttp.responseText);
            }
        }
        xmlhttp.open("GET","admin/employeemanagement/sendmail_board.php?id="+id+"&lang="+lang+"&company="+company,true);
	
        xmlhttp.send();
    }
    function onclickAddNewNotice(els){
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
                loadeditor();
            }
        }
        var lang = '<?= $_SESSION['lang'] ?>';
        xmlhttp.open("GET","admin/employeemanagement/new-general-notice.php?newlang="+lang,true);
        xmlhttp.send();

    }
    function loadeditor(){
        var editor = CKEDITOR.replace("ncontent",{language:"<?php
$lang_current = $_SESSION['lang'];
if (isset($lang_current)) {
    if ($lang_current == 'VN') {
        echo 'vi';
    } else if ($lang_current == 'KR') {
        echo 'ko';
    } else {
        echo 'en';
    }
} else {
    echo 'en';
}
?>", height:'100%', width:'100%'});
            CKFinder.setupCKEditor(editor, 'admin/ckfinder') ;
        }
        $(document).ready(function() {
            var editor = CKEDITOR.replace("ncontent",{language:"<?php
$lang_current = $_SESSION['lang'];
if (isset($lang_current)) {
    if ($lang_current == 'VN') {
        echo 'vi';
    } else if ($lang_current == 'KR') {
        echo 'ko';
    } else {
        echo 'en';
    }
} else {
    echo 'en';
}
?>", height:'100%', width:'100%'});
                CKFinder.setupCKEditor(editor, 'admin/ckfinder') ;
            });
            function onclickback(ele){
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
                    }
                }
                var lang = '<?= $_SESSION['lang'] ?>';
                xmlhttp.open("GET","admin/employeemanagement/genaral-notice.php?newlang="+lang,true);
                xmlhttp.send();

            }
            function processPreviewNotice(idboard,els){
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {

                        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	        
                    }
                }
                var lang = '<?= $_SESSION['lang'] ?>';
                xmlhttp.open("GET","admin/employeemanagement/preview-general-notice.php?idboard="+idboard+"&newlang="+lang,true);
                xmlhttp.send();
            }

            function processDeleteNotice(idboard,idemployee,els)
            {
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
                    }
                }
                var lang = '<?= $_SESSION['lang'] ?>';
                xmlhttp.open("GET","admin/employeemanagement/process-delete-general-notice.php?idboard="+idboard+"&idemp="+idemployee+"&newlang="+lang,true);
                xmlhttp.send();

            }
            function onclickEditGeneralNotice(idboard,action,els){
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {

                        document.getElementById("generalnotice").innerHTML=xmlhttp.responseText;
	        
                        loadeditor();
                    }
                }

                var lang = '<?= $_SESSION['lang'] ?>';
                xmlhttp.open("GET","admin/employeemanagement/new-general-notice.php?idboard="+idboard+"&action="+action+"&newlang="+lang,true);
                xmlhttp.send();

                function loadeditor(){
                    var editor = CKEDITOR.replace("ncontent");
                    CKFinder.setupCKEditor(editor, '../ckfinder') ;
                }
            }
</script>
<input type="hidden" id="orderid" value=""/>
<input type="hidden" id="lang" value=""/>
<input type="hidden" id="company" value="" />
<div id="contains" style="background-color: #edf4f7;">
    <div class="title">
        <div
            style="color: #0962C8; font-size: 12px; font-weight: bold; padding-left: 2px; padding-top: 8px; text-transform: uppercase;"></div>
    </div>
    <div class="body" style="margin-left: 5px;" id="generalnotice">
        <div style="height: 10px;"></div>
        <div class="navigation-button">
            <a href="general-notices-admin.php?content=new-general-notice" ><img
                    src="images/new.png" /> </a>
            <div><?php echo $l_addnew ?></div>
        </div>
        <br style="clear: both" /> <br />

        <table class="board" width="100%">
            <tr>
                <th align="center" width="5%"><?php echo $l_no ?></th>
                <!-- <th width="3%"></th> -->
                <th width="50"><?php echo $l_title ?></th>
                <th width="15%"><?php echo $l_author ?></th>
                <th width="10%"><?php echo $l_created_date ?></th>
                <th width="10%"><?php echo $l_views ?></th>
                <th width="10%"></th>
            </tr>
            <?php
            $i = 0;
            while ($row = mysql_fetch_array($loadboard)) {
                $i++;
                ?>
                <tr>
                    <td align="center" width="5%"><?php echo $i; ?>
                    </td>
                    <!-- 
                    <td align="left"><?php if ($row[Type] == "VN") { ?> <img
                                        					src="images/flag_12.gif" height="15" width="18" /> <?php } else if ($row[Type] == "KR") { ?>
                                                <img src="images/flag_14.gif" height="15" width="18" /> <?php } ?>
                    				</td> -->
                    <td width="50"><a href="#" onclick="processPreviewNotice('<?= $row[ID] ?>',this);"><?php echo $row[Title] ?> </a>
                    </td>
                    <td align="center" width="15%"><?php echo $row[FullName] ?></td>
                    <td align="center" width="10%"><?php echo $row[CreatedDate] ?></td>
                    <td align="center" width="5%"><?php echo $row[View] ?></td>
                    <td align="center" width="15%">
                        <a onclick="setdata('<?= $row[ID] ?>','<?= $lang ?>','<?= $temp[0] ?>')" title="<?php echo $l_sendmail ?>" > <img src="images/send.png" style="width: 17px" /> </a> 
                        <a onclick="processPreviewNotice('<?= $row[ID] ?>',this);" title="<?php echo $l_View ?>"
                           style="padding-left: 10px"> <img src="images/view.png" /> </a> 
                        <a href="general-notices-admin.php?content=new-general-notice&idboard=<?= $row[ID] ?>&action=edit&newlang=<?= $lang ?>" 
                           style="padding-left: 10px"  
                           title="<?php echo $l_edit ?>"> <img src="images/edit-admin.png" /></a>
                        <a style="padding-left: 10px" onclick="if(confirm('<?php echo $l_confirm_deleteproject ?>')){ processDeleteNotice('<?= $row[ID] ?>','<?= $id_employee ?>',this); return true;}else{return false;}"
                           title="<?php echo $l_delete ?>" ><img src="images/delete-admin.png" /></a>
                    </td>
                <?php } ?>

        </table>

    </div>
</div>
